package com.hwatsang.dao.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.hwatsang.dao.ProductDao;
import com.hwatsang.model.Product;
import com.hwatsang.model.User;

public class HibernateProductDaoImpl extends HibernateDaoSupport implements ProductDao {

	private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUserDaoImpl.class);
	
	@Override
	public String createProduct(Product product) {
		LOGGER.debug("Creating product [name={}, serial_number={}].", product.getName(), product.getSerialNumber()) ;
		
		return String.valueOf(getHibernateTemplate().save(product));		
	}

	@Override
	public Product getProductById(String productId) {
		LOGGER.debug("Getting product with id {}.", productId);
		
		return getHibernateTemplate().get(Product.class, Long.valueOf(productId));	
	}

	@Override
	public boolean updateProduct(Product product) {
		LOGGER.debug("Updating product with id {}.", product.getId());
		
		getHibernateTemplate().update(product);
		return true;
	}

	@Override
	public boolean deleteProductById(String productId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String getProductPicturePath(String productId) {
		// TODO Auto-generated method stub
		return null;
	}

}
